﻿
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UIModel.UIModel.Member
{
    /// <summary>
    /// 活动详情
    /// </summary>
    public class LkdrwInf
    {
        public LkdrwInf() { }

        public LkdrwInf(LkdrwInf self)
        {
            this.Lkdrw = self.Lkdrw;
       
        }

        public MongoLkdrw Lkdrw { get; set; } = new MongoLkdrw();
       
    }

    /// <summary>
    /// 因mongo不同,所以需要更改时间
    /// </summary>
    public class MongoLkdrw
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        /// <summary>
        /// 主键：票据号
        /// </summary>
        [Description("票据号")]
        public string BllNo { get; set; }


        /// <summary>
        /// 企业代码
        /// </summary>
        [Description("企业代码")]
        public string CpnID { get; set; }

        /// <summary>
        /// 公众号
        /// </summary>
        [Description("公众号")]
        public string SubID { get; set; }

        /// <summary>
        /// 主题
        /// </summary>
        [Description("主题")]
        public string Sbjc { get; set; }

        /// <summary>
        /// 活动主图
        /// </summary>
        [Description("活动主图")]
        public string Pic { get; set; }

        /// <summary>
        /// 活动描述
        /// </summary>
        [Description("活动描述")]
        public string Intro { get; set; }

        /// <summary>
        /// 活动类型
        /// </summary>
        [Description("活动类型")]
        public Int32 ActvType { get; set; }



        /// <summary>
        /// 活动执行时间段
        /// </summary>
        [Description("活动执行时间段")]
        public string TimeSlot { get; set; }

        /// <summary>
        /// 礼品池生成类型
        /// </summary>
        [Description("礼品池生成类型")]
        public Int32 GftPoolTyp { get; set; }


        /// <summary>
        /// 计算类型
        /// </summary>
        [Description("计算类型")]
        public Int32 Lktype { get; set; }


        /// <summary>
        /// 会员类型
        /// </summary>
        [Description("会员类型")]
        public string VipTp { get; set; }

        /// <summary>
        /// 执行机构[All表示所有门店]
        /// </summary>
        [Description("执行机构")]
        public string OrgIDs { get; set; }

        /// <summary>
        /// 执行商铺[All表示所有商铺]
        /// </summary>
        [Description("执行商铺")]
        public string StoreIDs { get; set; }

        /// <summary>
        /// 最低数值
        /// </summary>
        [Description("最低数值")]
        public decimal LttAmt { get; set; }

        /// <summary>
        /// 最低数值是否包含优惠[0-不包含、1-包含]
        /// </summary>
        [Description("最低数值是否包含优惠")]
        public Int32 HasPre { get; set; }

        /// <summary>
        /// 最大抽奖次数
        /// </summary>
        [Description("最大抽奖次数")]
        public Int32 MaxNum { get; set; }

        /// <summary>
        /// 每人每日领取次数
        /// </summary>
        [Description("每人每日领取次数")]
        public Int32 DayDegre { get; set; }

        /// <summary>
        /// 活动中奖机率
        /// </summary>
        [Description("活动中奖机率")]
        public decimal LttPrb { get; set; }

        /// <summary>
        /// 是否会员专享[0-否、1-是]
        /// </summary>
        [Description("是否会员专享")]
        public Int32 IsReg { get; set; }

        /// <summary>
        /// 是否要求分享[0-否、1-是]
        /// </summary>
        [Description("是否要求分享")]
        public Int32 IsShr { get; set; }

        /// <summary>
        /// 要求参与拆礼盒人数
        /// </summary>
        [Description("要求参与拆礼盒人数")]
        public Int32 JoinAmt { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Description("备注")]
        public string Brf { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Description("状态")]
        public Int32 Stt { get; set; }

        /// <summary>
        /// 是否终止[0-正常、-1-终止]
        /// </summary>
        [Description("是否终止")]
        public Int32 IsStop { get; set; }

        /// <summary>
        /// 删除状态[N-正常、Y-删除]
        /// </summary>
        [Description("删除状态")]
        public string Deleted { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>
        [Description("状态")]
        public Int32 Uptr { get; set; }


        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? Lktsdt { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? Lktedt { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? GetEdDt { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? Sdt { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? Edt { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime UptDtt { get; set; }
    }

   
    /// <summary>
    /// 活动缓存对象
    /// </summary>
    public class CacheLkdrwInf : LkdrwInf
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        public CacheLkdrwInf() { }

        public CacheLkdrwInf(LkdrwInf self) : base(self)
        {

        }
        /// <summary>
        /// 主键
        /// </summary>
       
        public string CpnID { get; set; }
        public string SubID { get; set; }
        public string BllID { get; set; }
        public DateTime ExpiresDate { get; set; } = DateTime.Now;
    }

    /// <summary>
    /// 礼品缓存对象
    /// </summary>
    public class CacheLkdrwGft : CacheLkdrwInf
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        public CacheLkdrwGft(LkdrwInf self) : base(self)
        { }
        public List<CacheGft> gftLst { get; set; } = new List<CacheGft>();

        public CacheGft NullCacheGft { get; set; } = null;

    }
    /// <summary>
    /// 礼品缓存对象 -- 礼品
    /// </summary>
    public class CacheGft
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        /// <summary>
        /// 主键
        /// </summary>
     
        public string CpnID { get; set; }
        public string SubID { get; set; }
        public String BllId { get; set; } = String.Empty;
        public Int32 Lvl { get; set; } = -1;
        public String LvlName { get; set; } = String.Empty;
        public Int32 IsFix { get; set; } = 0;

        public Int32 Winning { get; set; } = 0;

        public List<CacheGftInf> LvlGftList { get; set; } = new List<CacheGftInf>();
    }

    /// <summary>
    /// 礼品缓存对象 -- 礼品对象
    /// </summary>
    public class CacheGftInf
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        /// <summary>
        /// 礼品类型
        /// </summary>
        public Int32 GftType { get; set; } = -1;
        /// <summary>
        /// 礼品类型名
        /// </summary>
        public String GftTypeName { get; set; } = String.Empty;
        /// <summary>
        /// 礼品ID 积分时为空值
        /// </summary>
        public String GftId { get; set; } = String.Empty;
        /// <summary>
        /// 礼品名  积分时为积分
        /// </summary>
        public String GftTitle { get; set; } = String.Empty;
        /// <summary>
        /// 非积分时 图片
        /// </summary>
        public String GftPic { get; set; } = String.Empty;
        /// <summary>
        /// 获奖数量
        /// </summary>
        public Decimal GftValue { get; set; } = 0;
    }

    /// <summary>
    /// 中奖用户缓存池对象
    /// </summary>
    public class CacheUsr
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        /// <summary>
        /// 主键
        /// </summary>
    
        public String JoinKey { get; set; }
        public String OpenID { get; set; }
        public DateTime? UptDtt { get; set; }
        public string CpnID { get; set; }
        public string SubID { get; set; }
        public string BllNo { get; set; }
        public CacheGft CacheGft { get; set; }
    }

    
    /// <summary>
    /// 用户活动详情
    /// </summary>
    public class LkdrwUsr : LkdrwInf
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        /// <summary>
        /// 用户openID
        /// </summary>
        public String UsrOpnId { get; set; } = String.Empty;
        /// <summary>
        /// 活动当前参与数量
        /// </summary>
        public Int32 AllUsrJoinNum { get; set; } = 0;
        /// <summary>
        /// 当前用户参与数量
        /// </summary>
        public Int32 UsrJoinNum { get; set; } = 0;
        /// <summary>
        /// 当前中奖数量
        /// </summary>
        public Int32 AllUsrGftNum { get; set; } = 0;
        /// <summary>
        /// 当前用户中奖数量
        /// </summary>
        public Int32 UsrGftNum { get; set; } = 0;
    }

    public class DbRowCountNum
    {
        public MongoDB.Bson.ObjectId _id { get; set; }
        public Int32 CountNum { get; set; } = 0;
    }
}
